package thread.countDownLantch;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

public class CountDownLantchTest implements Runnable {

   final static  int size = 10;

    static CountDownLatch countDownLatch = new CountDownLatch(size);

    public static void main(String[] args) throws InterruptedException {
        for (int i=0;i<size;i++){
            Thread thread = new Thread(new CountDownLantchTest());
            thread.start();
            try {
                TimeUnit.SECONDS.sleep(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        countDownLatch.await();
        System.out.println("火箭发射......");
    }

    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName()+":检查工作完成");
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        countDownLatch.countDown();
    }
}
